// Copyright (C) 2010, Scott W. Dunlop <swdunlop@gmail.com>
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//    * Redistributions of source code must retain the above copyright
//      notice, this list of conditions and the following disclaimer.
//    * Redistributions in binary form must reproduce the above copyright
//      notice, this list of conditions and the following disclaimer in the
//      documentation and/or other materials provided with the distribution.
//    * Neither the name of the <organization> nor the
//      names of its contributors may be used to endorse or promote products
//      derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
// ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef NOSPEX_WINDOW_H
#define NOSPEX_WINDOW_H 1

#ifndef NOSPEX_DATA_H
#error "Do not include NoSpex header files directly instead use nospex.h"
#endif

#include <SDL.h>
#include <cairo.h>

typedef struct nx_window_t* nx_window_p;
struct nx_window_t {
    struct nx_resource_t rsrc;

    nx_graph_p graph;
    cairo_surface_t* cairo_surface;
    SDL_Surface* sdl_surface;
};

/** Creates a SDL graph window. */
nx_window_p nx_create_window( nx_graph_p graph );

/** Unlinks an SDL graph window, currently unimplemented. */
void nx_unlink_window( nx_window_p window );

/** Request a redraw no more than 50 milliseconds into the future. */
void nx_request_graph_render( nx_graph_p graph );

/** Request a period of physics application, consuming all available CPU. */
void nx_request_graph_physics( nx_graph_p graph );

/** Request periodic blip updates until there are no more blips. */
void nx_request_graph_blips( nx_graph_p graph );

/** Interrupts the SDL thread. */
void nx_seize_control( );

/** Releases the SDL thread. */
void nx_release_control( );

/** Runs the window loop. */
void nx_window_loop( nx_window_p window );

/** Initialize SDL overhead. */
void nx_initialize_sdl( );

#endif //#ifndef NOSPEX_WINDOW_H

